'use client'; import { useEffect, useRef } from 'react'; import { useParams } from 'next/navigation'; import { useAppDispatch } from '@akinon/next/redux/hooks'; import { setCurrentStep } from '@akinon/next/redux/reducers/checkout'; import { ROUTES } from '@theme/routes'; import { useFetchCheckoutResultQuery } from '@akinon/next/data/client/checkout'; import { CheckoutStep } from '@akinon/next/types'; import { CarouselCore } from '@theme/components/carousel-core'; import { Price, Button, Icon, LoaderSpinner, Link } from '@theme/components'; import { CheckoutStepList } from '@theme/views/checkout'; import { useLocalization } from '@akinon/next/hooks'; import { Image } from '@akinon/next/components/image'; import { Trans } from '@akinon/next/components/trans'; import { pushPurchaseEvent } from '@theme/utils/gtm'; const CheckoutCompleted = () => { const params = useParams<{ token: string }>(); const { t } = useLocalization(); const dispatch = useAppDispatch(); const { data, isLoading } = useFetchCheckoutResultQuery(String(params.token)); const carouselRef = useRef(null); const goToPrev = () => { carouselRef.current?.previous(); }; const goToNext = () => { carouselRef.current?.next(); }; useEffect(() => { dispatch(setCurrentStep(CheckoutStep.Confirmation)); return () => { dispatch(setCurrentStep(CheckoutStep.Shipping)); }; }, []); // eslint-disable-line react-hooks/exhaustive-deps useEffect(() => { if (data?.order) { pushPurchaseEvent(data?.order); } }, [data]); if (isLoading) { return (
{t('checkout.completed.thank_you')}
{t('checkout.completed.purchase_info')}
{t('checkout.completed.side.description_first')}
{t('checkout.completed.side.description_second')}: